package com.itheima.tcp;

import java.io.*;
import java.net.Socket;

/**
 * @Author 王加鑫
 * @Date 2021/5/25 16:49
 * @Version 1.0
 */
public class ClientDemo02 {
    public static void main(String[] args) throws IOException {

        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("C:\\Users\\JiaXin\\Pictures\\Camera Roll\\3D绘画 女仆 美腿 黑丝 高跟鞋 两位女仆进门后的一幕 4k动漫壁纸_彼岸图网.jpg"));
        Socket socket = new Socket("192.168.22.77",10001);
        BufferedOutputStream bos = new BufferedOutputStream(socket.getOutputStream());

        byte[] bytes = new byte[1024*1024];
        int i;
        while ((i = bis.read(bytes)) != -1){
            bos.write(bytes,0,i);
            bos.flush();
        }
        socket.shutdownOutput();

        InputStream is = socket.getInputStream();
        byte[] b1 = new byte[1024];
        int i1;
        while ((i1 = is.read(b1)) !=-1){
            System.out.println(new String(b1,0,i1));
        }

        bis.close();
        socket.close();
        bos.close();

    }
}
